package com.wk.fe;

public class SwitchTest {
    public static void main(String[] args) {
        Object a = "Hello";
        if (a instanceof String b) {
            System.out.println(b);
        }
        if (a instanceof Integer b) {
            System.out.println(b);
        }
        if (a instanceof Long b) {
            System.out.println(b);
        }
        // ---> switch 优化

// jdk21
//        switch (a) {
//            case String b -> System.out.println(b);
//            case Integer b -> System.out.println(b);
//            case Long b -> System.out.println(b);
//            default -> throw new IllegalStateException("Unexpected value: " + a);
//        }
    }
}
